<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>子传父组件</title>
		<script src="../../vue/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<zj1></zj1>
		</div>
		<!-- 父组件 -->
		<template id="zj1">
			<div id="">
				<button type="button" v-for="item in list" @click="btnClick(item)">{{item.name}}</button>
			</div>
			
		</template>
		<!-- 子组件 -->
		<template id="zj2">
			<div id="">
				<p>你好呀！</p>
			</div>
			
		</template>
		<script type="text/javascript">
				Vue.component('zj1',{
					template:'#zj1',
					data(){
						return{
							list:[
								{id:'1',name:'热门推荐'},
								{id:'2',name:'手机数码'},
								{id:'3',name:'家电'},
								{id:'4',name:'电脑办公'}
								
							]
						}
					},
					methods:{
						btnClick(item){
							console.log(item);
						}
					}
				});
				Vue.component('zj2',{
					template:'#zj2',
					data(){
						return{
							
						}
					}
				});
				
			var spp = new Vue({
				el:'#app',
				data:{
					
				}
			});
		</script>
	</body>
</html>
